<?php
/**
 * Created by PhpStorm.
 * User: zhangrongxiang
 * Date: 2018/1/23
 * Time: 下午11:42
 */


//不用新变量直接交换现有两个变量的值

$a = 100;
$b = 200;
//1：
list($a, $b) = array($b, $a);
echo $a,$b;
//2：
$a = $a . $b;
$b = strlen($b);
$b = substr($a, 0, (strlen($a) - $b));
$a = substr($a, strlen($b));
echo $a,$b;

//3:(必须用一个两个字符串都都不能出现的字符做为分隔符)
$a = $b . ',' . $a;
$a = explode(',', $a);
$b = $a[1];
$a = $a[0];

//4：这个是当两个数都是数字的时候:
$a = $a + $b;
$b = $a - $b;
$a = $a - $b;

//5：借助数组
$a = array($a, $b);
$b = $a[0];
$a = $a[1];